<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    *{
        margin:0;
        padding:0;
    }
</style>
<style>
    .showdiv{
        width:1200px;
        height: 1200px;
        background-color: #666666;
        margin:0px auto;
    }
    .headdiv{
         width: 100%;
         height: 50px;
         position: sticky;
         top: 0px;
         background-color: #2aabd2;
    }
    .main{
         position: relative;
    }
    .headtop{
         height: 50px;
    }
</style>
<body>
    <!-- <div style="position: relative;">
        <div style="height:50px;background:#f00;">
            dfsfs
        </div>
        <div style="height:50px;background:#ff0;position: sticky;top:0px;">我是一个大哥</div>
    <div style="height: 100vh;">
        1
    </div>
    </div> -->
    
    <!--第一种-->
        <div class="main">
            <div class="headtop">
    
            </div>
            <div class="headdiv">
    
            </div>
            <div class="showdiv">
    
            </div>
        </div>
</body>
</html>